home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / public / ghostscript / src / gsmatrix.h < prev    next >
C/C++ Source or Header  |  1994-08-01  |  3KB  |  74 lines

  1. /* Copyright (C) 1989, 1990, 1991 Aladdin Enterprises.  All rights reserved.
  2.  
  3. This file is part of Ghostscript.
  4.  
  5. Ghostscript is distributed in the hope that it will be useful, but
  6. WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
  7. to anyone for the consequences of using it or for whether it serves any
  8. particular purpose or works at all, unless he says so in writing.  Refer
  9. to the Ghostscript General Public License for full details.
  10.  
  11. Everyone is granted permission to copy, modify and redistribute
  12. Ghostscript, but only under the conditions described in the Ghostscript
  13. General Public License.  A copy of this license is supposed to have been
  14. given to you along with Ghostscript so you can know your rights and
  15. responsibilities.  It should be in a file named COPYING.  Among other
  16. things, the copyright notice and this notice must be preserved on all
  17. copies.  */
  18.  
  19. /* gsmatrix.h */
  20. /* Definition of matrices and matrix routines for Ghostscript library */
  21.  
  22. #ifndef gsmatrix_INCLUDED
  23. #  define gsmatrix_INCLUDED
  24.  
  25. /* See p. 65 of the PostScript manual for the semantics of */
  26. /* transformation matrices. */
  27.  
  28. /* Structure for a transformation matrix. */
  29. /* This is a machine-dependent hack to avoid importing */
  30. /* the full definition of a Ghostscript type-tagged reference. */
  31. #define _matrix_body\
  32.     long _xx /*skip*/; float xx;\
  33.     long _xy /*skip*/; float xy;\
  34.     long _yx /*skip*/; float yx;\
  35.     long _yy /*skip*/; float yy;\
  36.     long _tx /*skip*/; float tx;\
  37.     long _ty /*skip*/; float ty
  38. struct gs_matrix_s {
  39.     _matrix_body;
  40. };
  41. #ifndef gs_matrix_DEFINED
  42. #  define gs_matrix_DEFINED
  43. typedef struct gs_matrix_s gs_matrix;
  44. #endif
  45. /* Macro for initializing constant matrices */
  46. #define constant_matrix_body(xx, xy, yx, yy, tx, ty)\
  47.     0L,(float)(xx), 0L,(float)(xy), 0L,(float)(yx),\
  48.     0L,(float)(yy), 0L,(float)(tx), 0L,(float)(ty)
  49.  
  50. /* The identity matrix (for structure initialization) */
  51. #define identity_matrix_body\
  52.     constant_matrix_body(1, 0, 0, 1, 0, 0)
  53.  
  54. /* Matrix creation */
  55. void    gs_make_identity(P1(gs_matrix *));
  56. int    gs_make_translation(P3(floatp, floatp, gs_matrix *)),
  57.     gs_make_scaling(P3(floatp, floatp, gs_matrix *)),
  58.     gs_make_rotation(P2(floatp, gs_matrix *));
  59.  
  60. /* Matrix arithmetic */
  61. int    gs_matrix_multiply(P3(const gs_matrix *, const gs_matrix *, gs_matrix *)),
  62.     gs_matrix_invert(P2(const gs_matrix *, gs_matrix *)),
  63.     gs_matrix_rotate(P3(const gs_matrix *, floatp, gs_matrix *));
  64.  
  65. /* Coordinate transformation */
  66. int    gs_point_transform(P4(floatp, floatp, const gs_matrix *, gs_point *)),
  67.     gs_point_transform_inverse(P4(floatp, floatp, const gs_matrix *, gs_point *)),
  68.     gs_distance_transform(P4(floatp, floatp, const gs_matrix *, gs_point *)),
  69.     gs_distance_transform_inverse(P4(floatp, floatp, const gs_matrix *, gs_point *)),
  70.     gs_bbox_transform(P3(gs_rect *, const gs_matrix *, gs_rect *)),
  71.     gs_bbox_transform_inverse(P3(gs_rect *, const gs_matrix *, gs_rect *));
  72.  
  73. #endif                    /* gsmatrix_INCLUDED */
  74.